package com.yunshan.welfare;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.welfare.domain.WelfareGiftContent;
import com.yunshan.welfare.service.IWelfareGiftContentService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 礼包内容Controller
 *
 * @author yunshan
 * @date 2025-01-20
 */
@RestController
@RequestMapping("/welfare/giftContent")
public class WelfareGiftContentController extends BaseController
{
    @Autowired
    private IWelfareGiftContentService welfareGiftContentService;

    /**
     * 查询礼包内容列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WelfareGiftContent welfareGiftContent)
    {
        startPage();
        List<WelfareGiftContent> list = welfareGiftContentService.selectWelfareGiftContentList(welfareGiftContent);
        return getDataTable(list);
    }

    /**
     * 导出礼包内容列表
     */
    @Log(title = "礼包内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WelfareGiftContent welfareGiftContent)
    {
        List<WelfareGiftContent> list = welfareGiftContentService.selectWelfareGiftContentList(welfareGiftContent);
        ExcelUtil<WelfareGiftContent> util = new ExcelUtil<WelfareGiftContent>(WelfareGiftContent.class);
        util.exportExcel(response, list, "礼包内容数据");
    }

    /**
     * 获取礼包内容详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(welfareGiftContentService.selectWelfareGiftContentById(id));
    }

    /**
     * 新增礼包内容
     */
    @Log(title = "礼包内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WelfareGiftContent welfareGiftContent)
    {
        return toAjax(welfareGiftContentService.insertWelfareGiftContent(welfareGiftContent));
    }

    /**
     * 修改礼包内容
     */
    @Log(title = "礼包内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WelfareGiftContent welfareGiftContent)
    {
        return toAjax(welfareGiftContentService.updateWelfareGiftContent(welfareGiftContent));
    }

    /**
     * 删除礼包内容
     */
    @Log(title = "礼包内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(welfareGiftContentService.deleteWelfareGiftContentByIds(ids));
    }
}
